// pages/article/article.js
Page({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    _id: '',
    article: {},
    isAdmin: getApp().globalData.isAdmin,
  },

  onLoad(options){
    const _id = options._id;
    console.log('20-20 articleDetail.js:::::options._id:::', options._id);
    this.setData({
      _id: _id
    })
    this.getDetail(_id);
  },

    getDetail(_id){
      const that = this;
      const articleDoc = getApp().globalData.articleDoc;
      console.log('28-28 articleDetail.js:::::getDetail:::_id:', _id);
      articleDoc.doc(_id).get({
        success(res){
          console.log(`33-33 articleDetail.js:::::getDetail:::success::res`, res, 'res.data', res.data);
          that.setData({
            article: res.data.article,
          })
        },
        fail(err){
          console.log(`30-30 articleDetail.js:::::getDetail:::fail::err:`, err);
        },
      })
    },


    editArticle(){
      const _id = this.data._id;
      wx.navigateTo({
        url: `/pages/articleForm/articleForm?_id=${_id}`,
        success: (res) => {},
        fail: (err) => {
          console.log('18-18 articleList.js:::::editArticle:::fail::err:', err);
        },
        complete: (res) => {},
      });
    },

})
